package com.byapp.fast.common.utils;

import com.byapp.fast.common.enums.ResultEnum;
import com.byapp.fast.common.vo.ResultVO;

/**
 * 结果集封装工具类
 */
public class ResultUtils {

    public static ResultVO success() {
        return success(ResultEnum.SUCCESS, null);
    }

    public static ResultVO success(Object data) {
        return success(ResultEnum.SUCCESS, data);
    }

    public static ResultVO success(ResultEnum resultEnum, Object data) {
        return new ResultVO()
                .setCode(resultEnum.getCode())
                .setMsg(resultEnum.getMsg())
                .setData(data);
    }

    public static ResultVO error() {
        return error(ResultEnum.ERROR);
    }

    public static ResultVO error(ResultEnum resultEnum) {
        return new ResultVO()
                .setCode(resultEnum.getCode())
                .setMsg(resultEnum.getMsg());
    }

    public static ResultVO error(Integer code, String msg) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(code);
        resultVO.setMsg(msg);
        return resultVO;
    }


}
